fix(ci): move the repo user-agent to where pnpm v12 reads it - #10552
fix(ci): move the repo user-agent to where pnpm v12 reads it#10552zkochan wants to merge 4 commits into
Conversation
PR Summary by QodoFix CI: prevent CircleCI user-agent from persisting in tracked .npmrc
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Unprovisioned pnpm command
|
bdd8d67 to
5cd15a5
Compare
| @@ -1,13 +0,0 @@ | |||
| user-agent=bit-repo-local | |||
There was a problem hiding this comment.
1. Repo npmrc user-agent removed 🐞 Bug ◔ Observability
The tracked .npmrc has been deleted and the setup_harmony job no longer sets user-agent=bit-repo-circleci before running bbit install, removing the repo- and CI-level explicit user-agent override. Since Bit’s pnpm integration reads the resolved npmrc/pnpm config.userAgent to choose a network user-agent, installs may now run with a different (fallback/default) user-agent than before.
Agent Prompt
## Issue description
The PR removes the explicit npm user-agent configuration by deleting the tracked `.npmrc` and by stopping `setup_harmony` from setting a CI-specific `user-agent=bit-repo-circleci` before `bbit install`. Because Bit’s pnpm integration derives the network user-agent from the resolved pnpm/npmrc config (`config.userAgent`) when available, this can change the user-agent used for network operations and remove the intended request-identification marker in CI.
## Issue Context
- Bit’s pnpm package manager uses the resolved pnpm config’s `userAgent` when present, and falls back when it is not.
- Previously, the repo had a `.npmrc`-level `user-agent` setting that influenced the resolved config.
- Previously, the `setup_harmony` job appended `user-agent=bit-repo-circleci` to `.npmrc` right before installing; now the job runs `cd bit && bbit install` without setting a user-agent.
- If a stable marker is still desired, CI-specific configuration should not be introduced via mutating tracked workspace state.
## Fix Focus Areas
- scopes/dependencies/pnpm/pnpm.package-manager.ts[312-320]
- .npmrc[1-13]
- .circleci/config.yml[638-642]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 5cd15a5 |
|
Code review by qodo was updated up to the latest commit 4de67bf |
setup_harmony appended `user-agent=bit-repo-circleci` to the tracked .npmrc and then persisted the checkout, so the job that commits the version bump swept the mutated file into every release. The file had reached twelve copies of the line. The setting no longer does anything. pnpm v12 does not read `user-agent` from .npmrc: an install with `user-agent=bit-repo-local` in .npmrc sends the default `pnpm/<version> ...` header, and bit's own installs send `bit user/<username>` from getNetworkConfig, which reads bit config rather than .npmrc. Both names have been inert since the pnpm v12 migration, and before that the twelve committed CI lines overrode `bit-repo-local` for local work anyway, because the last duplicate key wins. Remove the append and the file instead of repairing a setting nothing reads. Local and CI installs now share one user agent, bit's own. The knobs that do work under v12, should this traffic ever need marking again, are `pnpm_config_user_agent` in the environment and `userAgent` in pnpm-workspace.yaml. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
4de67bf to
1db165e
Compare
|
Code review by qodo was updated up to the latest commit 1db165e |
The local and CI markers stopped working: pnpm v12 reads settings like `user-agent` from pnpm-workspace.yaml rather than .npmrc, and Bit resolves its network config through the package-manager config rather than the repository .npmrc. Set the tracked default to `userAgent: bit-repo` in pnpm-workspace.yaml. In setup_harmony, override it with `pnpm config set --location=project userAgent bit-repo-circleci` before installation so registry traffic from CI remains distinguishable. Mark the file skip-worktree so the persisted checkout does not sweep this temporary override into a later release commit. Verified the project config resolves each marker with pnpm v12. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1db165e to
f80b0a2
Compare
| cd bit && | ||
| echo "user-agent=bit-repo-circleci" >> .npmrc && | ||
| git update-index --skip-worktree .npmrc && | ||
| pnpm config set --location=project userAgent bit-repo-circleci && |
There was a problem hiding this comment.
1. Unprovisioned pnpm command 🐞 Bug ☼ Reliability
setup_harmony now invokes pnpm config set without running the repository's setup_pnpm command, so a missing pnpm terminates the && chain before bbit install, while an ambient older pnpm may write the setting somewhere other than pnpm-workspace.yaml. The repository explicitly provisions and pins pnpm 12 for every existing direct pnpm workflow, but this job omits that setup.
Agent Prompt
## Issue description
`setup_harmony` directly invokes `pnpm config set`, but the job does not install or pin pnpm. This can either fail the job or use a pnpm version that does not implement the expected v12 project-config behavior.
## Issue Context
The repository already defines `setup_pnpm`, which installs pnpm 12.0.0-rc.7 and exports its binary directory through `$BASH_ENV`. Add that setup to `setup_harmony` before the direct pnpm invocation, or invoke the explicitly provisioned v12 binary by another reliable mechanism.
## Fix Focus Areas
- .circleci/config.yml[264-279]
- .circleci/config.yml[671-698]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit f80b0a2 |
|
Code review by qodo was updated up to the latest commit d06d5b6 |
Summary
The
user-agentin.npmrcexists so installs run inside this repository can be told apart from real users' installs at the registry. Two things were wrong with it.It stopped working. pnpm v12 reads settings like
user-agentfrompnpm-workspace.yaml, not.npmrc. Verified against a local server that logs request headers: withuser-agent=bit-repo-localin.npmrc, the install sent the defaultpnpm/12.0.0-alpha.21 npm/? node/? linux x64. Bit's own installs did not use it either, becausegetNetworkConfigtakesconfiguredUserAgentfrom the engine's resolved config (readConfig), which does not read it from.npmrc(scopes/dependencies/pnpm/pnpm.package-manager.ts:314-319).It accumulated one line per release.
setup_harmonyappended the marker to the tracked.npmrcand thenpersist_to_workspaced the checkout, so the job that creates the version-bump commit swept the mutated file into every release. The file had reached thirteen lines, twelve identical. And because duplicate keys in.npmrcare last-wins, those committed CI lines also overrodebit-repo-localfor anyone working locally, so the local/CI split had been inverted for twelve releases:What this PR does
pnpm-workspace.yamlwithuserAgent: bit-repo, which is where v12 reads it. Verified in this repo:readConfig({dir})returnsbit-repo, which is exactly the valuegetNetworkConfigforwards to the engine, so local and CI installs in this repo both carry the marker again.setup_harmony, so no tracked file is mutated and the accumulation cannot recur..npmrc, whose only contents were the deaduser-agentlines.One name now covers local and CI. The split was inverted for twelve releases, so nothing downstream can have been relying on it, and a single
bit-repois enough to filter this repo's traffic. If you do want them separated again, addpnpm_config_user_agent=bit-repo-circlecito the job environment: it overrides the file and needs no file mutation (verified, the request went out asbit-repo-circleci). Notenpm_config_user_agentdoes not work with v12, only thepnpm_config_prefix.Also worth knowing, though left out of scope here: the e2e job appends
user-agent=bit-e2e-circlecito~/.npmrc(.circleci/config.yml:542), which is inert for the same reason. The bvm bundle jobs are fine, since they write a throwaway.npmrcand run pnpm 10, which does honor it.Squash Commit Body
Checklist
readConfig({dir})in this repo returningbit-repo,bd installin this repo still succeeding with the new file present (332 components, no other tracked file touched), andyaml.safe_loadon.circleci/config.yml.pnpm-workspace.yaml.Written by an agent (Claude Code, claude-fable-5).